<?php
include("./include/config.inc.php");
$cfg_menuSelected[5] = 1;

if(isset($_POST['insertBtn']))
{
	$contactName = (isset($_POST['contactName'])) && ($_POST['contactName'] != "") ? $_POST['contactName'] : "" ;
	$email       = (isset($_POST['email'])) && ($_POST['email'] != "") ? $_POST['email'] : "" ;
	$website     = (isset($_POST['website'])) && ($_POST['website'] != "") ? $_POST['website'] : "" ;
	$conmessage  = (isset($_POST['conmessage'])) && ($_POST['conmessage'] != "") ? $_POST['conmessage'] : "" ;
	
  $insertQueryContact = "INSERT INTO contact (contactName,email,website,conmessage)
                            VALUES('".$contactName."',
                                   '".$email."',
                                   '".$website."',
                                   '".$conmessage."')";
    $insertQueryContactResult = mysql_query($insertQueryContact);
    if(!$insertQueryContactResult)
    {
      die("Insert Query Not Inserted : ".mysql_error());
    }
    else
    {
    $to = "$email";
    $subject = "Info Request";
    $message = ".$contactName.";
    $message = " Thanks For Visit Our Web site.\n\n";
    $message = "Thank you, \n\n";
    $message = "The Auto Responder \n\n\n";
    $headers = "Reply-To:" . $email . "\r\n";
    $mailsend = " mail($to, $subject, $message, $headers)";
    $to = "";
    $subject = "";
    $message = "";
    $headers = "";
    $mailsend = "";
	  $to = "vijayankolia@gmail.com"; 
	echo $subject = $contactName;
    $message = '<html><body>';
	  $message =  "<table rules='all' class='border_01' height=500 width=500 align='center'>
	                  <tr><td align='center' colspan='2'><h1>Contact Inquiry </h1> </td> </tr>
	                   
	                    <tr><td><b> Contact Name: </b>                   </td> <td>".$contactName."</td> </tr>
	                    <tr><td><b> Email: </b>                          </td> <td>".$email."</td> </tr>
	                    <tr><td><b> website:</b>                         </td> <td>".$website."</td> </tr>
	                    <tr><td><b> conmessage: </b>                     </td> <td>".$conmessage."</td> </tr>
	                     <tr><td align='center' colspan='2'></td> </tr>
	                 </table>";
	  $message .= "</body></html>";                        
	  "<br> Email  :  ".$from = $email;
	  $headers = "From:" . $from;
	  $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	  mail($to,$subject,$message,$headers);
    }
}
include("./bottom.php");
$smarty->display("contact.tpl");
?>